varying vec3 lightPos;
varying vec3 lightDir;

varying vec3 normal;

varying vec4 pos;

varying vec4 ProjShadow;

varying vec2 texture_coords;
uniform sampler2D baseTexture;
uniform sampler2DShadow myShadowMap;
//uniform sampler2D shadowMap;

void main()
{  
   vec3 toLight = normalize( lightDir );

   vec3 n = normalize( normal );

   float n_dot_l = dot( toLight, n );
   n_dot_l = max( 0.0, n_dot_l );

   n_dot_l *= 
      shadow2DProj( myShadowMap, ProjShadow ).r > 0.0 ? 1.0 : 0.5;
   
   vec4 mapping = texture2D( baseTexture, texture_coords );   

   vec4 baseColor = gl_Color * mapping;


   vec4 ambientColor = vec4( 0.0, 0.0, 0.0, 1 ) * mapping; 
//   gl_FragColor = vec4( baseColor.rgb * n_dot_l, 1 ) + ambientColor;
   gl_FragColor = baseColor * n_dot_l + ambientColor;
   gl_FragColor.a = 1.0;
} 

